package com.yusys.jin.blog.controller;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.yusys.jin.blog.entity.GameRole;
import com.yusys.jin.blog.service.IGameRoleService;
import com.yusys.jin.blog.util.ResponseResult;

@RestController
@RequestMapping("role")
public class RoleController extends BaseController {
    @Autowired
    IGameRoleService service;

    @PostMapping("addrole")
    public ResponseResult<Void> addRole(GameRole role, HttpSession session) {
        Integer uid = getUidFromSession(session);
        role.setUid(uid);

        String userName = getUsernameFromSession(session);
        service.addRole(role, userName);
        ResponseResult<Void> rr = new ResponseResult<Void>();
        rr.setState(200);
        rr.setMessage("添加角色成功");
        return rr;
    }
}
